﻿#include "stdafx.h"

#include "libOther.h"
#include "hiredis_interface.h"
#include "redisCli.h"
#include "redisReply.h"

#ifndef _STATIC

static INT cmdIndex_redisCli[] =
{
	13,14,15,16,17,18,19,20,21,22,
};
static LIB_DATA_TYPE_INFO DT_redisCli =
{
	/*m_szName*/					_T("redisCli"),
	/*m_szEgName*/					_WT(""),
	/*m_szExplain*/					_WT("提供对redis数据库操作支持."),
	/*m_nCmdCount*/					sizeArray(cmdIndex_redisCli),
	/*m_pnCmdsIndex*/				cmdIndex_redisCli,
	/*m_dwState*/					_DT_OS(OS_ALL),
	/*m_dwUnitBmpID*/				0,
	/*m_nEventCount*/				0,
	/*m_pEventBegin*/				NULL,
	/*m_nPropertyCount*/			0,
	/*m_pPropertyBegin*/			NULL,
	/*m_pfnGetInterface*/			NULL,
	/*m_nElementCount*/				0,
	/*m_pElementBegin*/				NULL,
};
static INT cmdIndex_redisReply[] =
{
	23,24,25,26,27,28,29,30,31,
};
static LIB_DATA_TYPE_INFO DT_redisReply =
{
	/*m_szName*/					_T("redisReply"),
	/*m_szEgName*/					_WT(""),
	/*m_szExplain*/					_WT("redis操作结果.进行相关操作前请务必先判断是否为空对象."),
	/*m_nCmdCount*/					sizeArray(cmdIndex_redisReply),
	/*m_pnCmdsIndex*/				cmdIndex_redisReply,
	/*m_dwState*/					_DT_OS(OS_ALL),
	/*m_dwUnitBmpID*/				0,
	/*m_nEventCount*/				0,
	/*m_pEventBegin*/				NULL,
	/*m_nPropertyCount*/			0,
	/*m_pPropertyBegin*/			NULL,
	/*m_pfnGetInterface*/			NULL,
	/*m_nElementCount*/				0,
	/*m_pElementBegin*/				NULL,
};

static LIB_DATA_TYPE_INFO s_DataType[] =
{
	DT_redisCli,
	DT_redisReply,
};
int g_DataTypeCount = sizeArray(s_DataType);
PLIB_DATA_TYPE_INFO g_DataType = s_DataType;


extern CMD_INFO Cmd_Other_FormatString;
extern CMD_INFO Cmd_redis_Connect;
extern CMD_INFO Cmd_redis_disConnect;
extern CMD_INFO Cmd_redis_isConnect;
extern CMD_INFO Cmd_redis_auth;
extern CMD_INFO Cmd_redis_Command;
extern CMD_INFO Cmd_redis_freeReply;
extern CMD_INFO Cmd_redis_getState;
extern CMD_INFO Cmd_redis_lastError;
extern CMD_INFO Cmd_redis_getInteger;
extern CMD_INFO Cmd_redis_getString;
extern CMD_INFO Cmd_redis_getCount;
extern CMD_INFO Cmd_redis_getElement;
//object-method
extern CMD_INFO Cmd_redisCli_construct;
extern CMD_INFO Cmd_redisCli_destruct;
extern CMD_INFO Cmd_redisCli_copy;
extern CMD_INFO Cmd_redisCli_connect;
extern CMD_INFO Cmd_redisCli_disconnect;
extern CMD_INFO Cmd_redisCli_isconnect;
extern CMD_INFO Cmd_redisCli_auth;
extern CMD_INFO Cmd_redisCli_runcommand;
extern CMD_INFO Cmd_redisCli_lasterrno;
extern CMD_INFO Cmd_redisCli_lasterror;
extern CMD_INFO Cmd_redisReply_construct;
extern CMD_INFO Cmd_redisReply_destruct;
extern CMD_INFO Cmd_redisReply_copy;
extern CMD_INFO Cmd_redisReply_isEmpty;
extern CMD_INFO Cmd_redisReply_getType;
extern CMD_INFO Cmd_redisReply_getInteger;
extern CMD_INFO Cmd_redisReply_getString;
extern CMD_INFO Cmd_redisReply_getCount;
extern CMD_INFO Cmd_redisReply_getElement;
static CMD_INFO s_CmdInfo[] =
{
	Cmd_Other_FormatString,
	Cmd_redis_Connect,
	Cmd_redis_disConnect,
	Cmd_redis_isConnect,
	Cmd_redis_auth,
	Cmd_redis_Command,
	Cmd_redis_freeReply,
	Cmd_redis_getState,
	Cmd_redis_lastError,
	Cmd_redis_getInteger,
	Cmd_redis_getString,
	Cmd_redis_getCount,
	Cmd_redis_getElement,
	Cmd_redisCli_construct,
	Cmd_redisCli_destruct,
	Cmd_redisCli_copy,
	Cmd_redisCli_connect,
	Cmd_redisCli_disconnect,
	Cmd_redisCli_isconnect,
	Cmd_redisCli_auth,
	Cmd_redisCli_runcommand,
	Cmd_redisCli_lasterrno,
	Cmd_redisCli_lasterror,
	Cmd_redisReply_construct,
	Cmd_redisReply_destruct,
	Cmd_redisReply_copy,
	Cmd_redisReply_isEmpty,
	Cmd_redisReply_getType,
	Cmd_redisReply_getInteger,
	Cmd_redisReply_getString,
	Cmd_redisReply_getCount,
	Cmd_redisReply_getElement,
};
int g_CmdInfoCount = sizeArray(s_CmdInfo);
PCMD_INFO	g_CmdInfo = s_CmdInfo;

static PFN_EXECUTE_CMD s_RunFunc[] =
{
	Other_FormatString,
	hiredis_connect,
	hiredis_disconnect,
	hiredis_isConnect,
	hiredis_auth,
	hiredis_command,
	hiredis_freeReply,
	hiredis_getState,
	hiredis_lastError,
	hiredis_getInteger,
	hiredis_getString,
	hiredis_getCount,
	hiredis_getElement,
	//object-method
	redis_redisCli_construct,
	redis_redisCli_destruct,
	redis_redisCli_copy,
	redis_redisCli_connect,
	redis_redisCli_disconnect,
	redis_redisCli_isconnect,
	redis_redisCli_auth,
	redis_redisCli_runcommand,
	redis_redisCli_lasterrno,
	redis_redisCli_lasterror,

	redis_redisReply_construct,
	redis_redisReply_destruct,
	redis_redisReply_copy,
	redis_redisReply_isempty,
	redis_redisReply_gettype,
	redis_redisReply_getinteger,
	redis_redisReply_getstring,
	redis_redisReply_getcount,
	redis_redisReply_getelement,
};

PFN_EXECUTE_CMD*	g_RunFunc = (PFN_EXECUTE_CMD*)s_RunFunc;

static const char* const s_CmdNames[] =
{
	"Other_FormatString",
	"hiredis_connect",
	"hiredis_disconnect",
	"hiredis_isConnect",
	"hiredis_auth",
	"hiredis_command",
	"hiredis_freeReply",
	"hiredis_getState",
	"hiredis_lastError",
	"hiredis_getInteget",
	"hiredis_getString",
	"hiredis_getCount",
	"hiredis_getElement",
	//object-method
	"redis_redisCli_construct",
	"redis_redisCli_destruct",
	"redis_redisCli_copy",
	"redis_redisCli_connect",
	"redis_redisCli_disconnect",
	"redis_redisCli_isconnect",
	"redis_redisCli_auth",
	"redis_redisCli_runcommand",
	"redis_redisCli_lasterrno",
	"redis_redisCli_lasterror",

	"redis_redisReply_construct",
	"redis_redisReply_destruct",
	"redis_redisReply_copy",
	"redis_redisReply_isempty",
	"redis_redisReply_gettype",
	"redis_redisReply_getinteger",
	"redis_redisReply_getstring",
	"redis_redisReply_getcount",
	"redis_redisReply_getelement",
};
const char* const *g_CmdNames = (char**)s_CmdNames;

#define ELE_ENUM(n,e,d,v) {_WT(n),_WT(e),_WT(d),LVL_SIMPLE,CT_NUM,NULL,v}

static LIB_CONST_INFO s_const_constVal[] =
{
	ELE_ENUM("REDIS_ERR","err","错误",REDIS_ERR),
	ELE_ENUM("REDIS_OK","ok","成功",REDIS_OK),
	ELE_ENUM("REDIS_ERR_IO","err_io","错误:IO错误",REDIS_ERR_IO),
	ELE_ENUM("REDIS_ERR_EOF","err_eof","错误:EOF无多的数据可读",REDIS_ERR_EOF),
	ELE_ENUM("REDIS_ERR_PROTOCOL","err_protocol","错误:协议错误",REDIS_ERR_PROTOCOL),
	ELE_ENUM("REDIS_ERR_OOM","err_oom","错误:内存错误",REDIS_ERR_OOM),
	ELE_ENUM("REDIS_ERR_OTHER","err_other","错误:其他错误",REDIS_ERR_OTHER),

	ELE_ENUM("REDIS_REPLY_STRING","String","记录类型:字符串",REDIS_REPLY_STRING),
	ELE_ENUM("REDIS_REPLY_ARRAY","Array","记录类型:数组",REDIS_REPLY_ARRAY),
	ELE_ENUM("REDIS_REPLY_INTEGER","Integer","记录类型:数字",REDIS_REPLY_INTEGER),
	ELE_ENUM("REDIS_REPLY_NIL","Null","记录类型:空值",REDIS_REPLY_NIL),
	ELE_ENUM("REDIS_REPLY_STATUS","Status","记录类型:状态",REDIS_REPLY_STATUS),
	ELE_ENUM("REDIS_REPLY_ERROR","Error","记录类型:错误",REDIS_REPLY_ERROR),
};
int g_ConstInfoCount = sizeArray(s_const_constVal);
PLIB_CONST_INFO g_ConstInfo = s_const_constVal;

#endif